import java.util.Arrays;
import java.util.Map;

public class Day0902 {
    //左右最值的最大差
    public int findMaxGap(int[] A, int n) {
        int max = 0;
        for (int i = 0; i <= n-2 ; i++) {
            int[] left = new int[i+1];
            int[] right = new int[n-i-1];
            for (int j = 0; j < n; j++) {
                if (j<=i)
                    left[j] = A[j];
                else
                    right[j-i-1] = A[j];
            }
            max = Max(left,right,max);
        }
        return max;
    }

    private int Max(int[] left, int[] right, int max) {
        Arrays.sort(left);
        Arrays.sort(right);

        if (max < Math.abs(left[left.length-1] - right[right.length-1])){
            max = Math.abs(left[left.length-1] - right[right.length-1]);
        }
        return max;
    }

    // 顺时针打印矩阵
//    public int[] clockwisePrint(int[][] mat, int n, int m) {
//
//    }
}
